package com.hugo.educms.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.hugo.commonutiles.R;
import com.hugo.educms.entity.CrmBanner;
import com.hugo.educms.service.CrmBannerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


import java.util.List;

@RestController
@RequestMapping("/educms/bannerFront")
@CrossOrigin
public class BannerFrontController {
    //查询所有banne

    @Autowired
    private CrmBannerService crmBannerService;
    @GetMapping("getAllBanner")
    public R getAllBanner(){
        //根据Id进行降序排序 显示排列后的前两条记录
        QueryWrapper<CrmBanner> wrapper = new QueryWrapper<>();
        wrapper.orderByDesc("id");
        //last  拼接sql语句
        wrapper.last("limit 2");
        List<CrmBanner> list = crmBannerService.selectAll();
        return R.ok().data("list",list);
    }
}
